package com.xywy.find;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.umeng.analytics.MobclickAgent;
import com.xywy.R;
import com.xywy.common.BaseFragment;
import com.xywy.common.FragmentMainActivity;
import com.xywy.common.constants.ConstantValue;

/**
 * 发现
 */
public class FindFragment extends BaseFragment {
	private FragmentMainActivity mactivity;
	private RelativeLayout rlJkgc;
	private RelativeLayout rlJkzh;
	private RelativeLayout rlJbzc;
	private RelativeLayout rlRemind;

	@Override
	public void onAttach(Activity activity) {
		super.onAttach(activity);
		mactivity = (FragmentMainActivity) activity;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	// 根布局
	private View rootView;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		rootView = inflater.inflate(R.layout.fragment_find, null);
		System.out.println("FindFragment ,  onCreateView");
		// 初始化View
		this.initView();

		this.setListener();
		return rootView;
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
	}

	/**
	 * 初始化View
	 */
	private void initView() {
		rlJkgc = (RelativeLayout) rootView.findViewById(R.id.rl_find_jkgc);
		rlJkzh = (RelativeLayout) rootView.findViewById(R.id.rl_find_jkzh);
		rlJbzc = (RelativeLayout) rootView.findViewById(R.id.rl_find_jbzc);
		rlRemind = (RelativeLayout) rootView.findViewById(R.id.rl_find_remind);

	}

	/**
	 * 事件监听
	 */
	private void setListener() {
		rlJkgc.setOnClickListener(onClickListener);
		rlJkzh.setOnClickListener(onClickListener);
		rlJbzc.setOnClickListener(onClickListener);
		rlRemind.setOnClickListener(onClickListener);
	}

	View.OnClickListener onClickListener = new View.OnClickListener() {
		@Override
		public void onClick(View view) {
			Class cl = null;
			switch (view.getId()) {
			case R.id.rl_find_jkgc:
				// cl = JkgcActivity.class;
				cl = NewJkgcActivity.class;
				// 健康广场
				// cl = JkgcPlazeActivity.class;
				break;
			case R.id.rl_find_jkzh:
				cl = JkzhActivity.class;
				break;
			case R.id.rl_find_jbzc:
				MobclickAgent.onEvent(mactivity, "B003");
				cl = JbzcActivity.class;
				break;
			case R.id.rl_find_remind:
				cl = RemindListActivity.class;
				break;
			}
			Intent intent = new Intent(mactivity, cl);
			startActivity(intent);
		}
	};

	/**
	 * Fragmengt唯一标识
	 * 
	 * @return
	 */
	@Override
	public int getID() {
		return ConstantValue.FG_FIND;
	}
}
